﻿/**
 * Copyright (c) 2008 - TheNittyGritty - Thomas Brekelmans
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
 
/**
 * Sets the FlashPlayer version and ActionScript version for all files in the 
 * same directory as where this file resides.
 */

/************\
 * Editable *
\************/
// Acceptable values are "FlashLite", "FlashLite11", "FlashLite20" , "1", "2", 
// "3", "4", "5", "6", "7", "8", and "9". These values correspond to the 
// Version drop-down list in the Publish Settings dialog box.
var PLAYER_VERSION = "9";

// Acceptable values are 1, 2, and 3. Note: make sure the combination of 
// PLAYER_VERSION and AS_VERSION is valid or they might not be set correctly!
var AS_VERSION = 3;

/****************\
 * Non-Editable *
\****************/
setPlayerPlusAsVersionForEachFileInTheCurrentDirectory()
function setPlayerPlusAsVersionForEachFileInTheCurrentDirectory()
{
	var currentDirectory = fl.scriptURI.substring(0, 
												  fl.scriptURI.lastIndexOf("/"));

	var flaFilesMask = "*.fla";
	var flaFilesInDirectory = FLfile.listFolder(currentDirectory + "/" 
												+ flaFilesMask, "files");
	
	var l = flaFilesInDirectory.length;
	
	if (l > 0)
	{
		var i = 0;
		for (i = 0; i < l; ++i)
		{
			var currentDocument = fl.openDocument(currentDirectory + "/" 
												  + flaFilesInDirectory[i]);
			currentDocument.setPlayerVersion(PLAYER_VERSION);
			currentDocument.asVersion = AS_VERSION;
			currentDocument.save(false);
		}
		
		fl.closeAll(false);
	}
	else
	{
		fl.trace("No .fla files were found in " + currentDirectory + ". 
				  The script did not run.");
	}
}